<?php
	if (!defined('EXPONENT')) exit('');
	if (exponent_permissions_check(array('administrate','configure',"create"),$loc)){
		$company=null; $id=0;
		$cat= null; $cat_id = 0;
		
		if (isset($_REQUEST['id']))
		{
			$id=intval($_REQUEST['id']);
			$company = $db->selectObject("surveymodule_companies","id = {$id}");
		}
			
		
		if (isset($_REQUEST['cat_id']))
		{
			$cat_id=intval($_REQUEST['cat_id']);
			$cat = $db->selectObject("surveymodule_catergory","id = {$cat_id}");
		}
			
		if ($company && $cat)
		{
			// select if already exist record in surveymodule_companies_services or not
			$data = $db->selectObject("surveymodule_companies_services"," (cat_id = {$cat_id}) AND (company_id = {$id})");
			
			if (!isset($data->id))
			{
				// insert new
				$data=null;
				$data->cat_id = $cat_id;
				$data->company_id = $id;
				$db->insertObject($data,"surveymodule_companies_services");
			}
		}
	}
	die();
?>